package com.clubmg.controller;

import com.clubmg.pojo.Club;
import com.clubmg.service.ChiefService;
import com.clubmg.service.MemberService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller("chiefController")
public class ChiefController {


    @Resource(name = "chiefService")
    private ChiefService chiefService;
    @Resource(name = "memberService")
    private MemberService memberService;


    @ResponseBody
    @RequestMapping("/getClubIManaged")
    public Club getClubIManaged(HttpSession session) {
        Long currentUid = (Long) session.getAttribute("uid");
        return chiefService.getClubIManaged(currentUid);
    }

    @ResponseBody
    @RequestMapping("/allow_join")
    public int allowJoin(Long applyUid, HttpSession session) {
        Long currentUid = (Long) session.getAttribute("uid");
        chiefService.allowJoin(applyUid, currentUid);
        return 0;
    }

    @ResponseBody
    @RequestMapping("/refuse_quit")
    public int refuseQuit(Long applyUid, HttpSession session) {
        Long currentUid = (Long) session.getAttribute("uid");
        chiefService.refuseQuit(applyUid, currentUid);
        return 0;
    }


    @ResponseBody
    @RequestMapping("/deregister_club")//注销社团
    public int deregisterClub(Long cid, HttpSession session) {
        Long currentUid = (Long) session.getAttribute("uid");
        return chiefService.deregisterClub(currentUid, cid);
    }

    //    /employ
    @ResponseBody
    @RequestMapping("/employ")
    public int employ(Long uid, Long cid, String position) {
        chiefService.employ(uid, cid, position);
        return 0;
    }

    @ResponseBody
    @RequestMapping({"/dismiss", "/deny"})
    public int dismissOrDeny(Long uid, Long cid, String position) {
        chiefService.dismissOrDeny(uid, cid, position);
        return 0;
    }
//

    @ResponseBody
    @RequestMapping("/publishnotice")
    public int publishNotice(Long cid, String title, String text) {
        chiefService.releaseNotice(cid, title, text);
        return 0;
    }

    @ResponseBody
    @RequestMapping("/cancelnotice")
    public int recallNotice(Long nid) {
        chiefService.recallNotice(nid);
        return 0;
    }

    @ResponseBody
    @RequestMapping("/hold_activity")
    public int holeActivity(Long cid, String place, String theme, String goal, String description) {
        memberService.holdActivity(cid,place,theme,goal,description);
        return 0;
    }


    @ResponseBody
    @RequestMapping("/test")
    public void Test() {
        chiefService.test();

    }


}
